import java.util.ArrayList;

/**
 * @projectName: LeetCode
 * @package: PACKAGE_NAME
 * @className: Point6
 * @author: Mocrash
 * @description: TODO
 * @date: 2024/10/18 12:19
 * @version: 1.0
 */
public class Point7 {
    public static void main(String[] args) {
        Solution solution = new Solution();
        int paypalishiring = solution.reverse(120);
        System.out.println(paypalishiring);
    }

    private static class Solution {
        public int reverse(int x) {
            int op = 1;
            long num = (long) x;
            if (num == 0) {
                return 0;
            } else if (num < 0) {
                num = -num;
                op = -1;
            }
            long res = num % 10;
            num /= 10;
            while (num != 0) {
                res = num % 10 + res * 10;
                num /= 10;
                if (res > Integer.MAX_VALUE || res < Integer.MIN_VALUE){
                    return 0;
                }
            }
            return (int) res * op;
        }
    }
}
